package office.service.person.impl;

import office.bo.hr.impl.CheckFolw;
import office.bo.person.Trip;
import office.dao.person.TripDP;
import office.service.finance.impl.CheckFolwServiceImpl;
import office.service.person.ITripService;
import platform.common.exception.BusinessException;

public class TripServiceImpl extends CheckFolwServiceImpl implements ITripService{

	@Override
	public CheckFolw getCheckFolwById(String id) throws BusinessException {
		Trip trip = null;
		try {
			trip = getDP(TripDP.class).findByIdAndDomain(id);
		} catch (Exception e) {
			log.error("", e);
			throw this.handleBusinessServiceException("设置审批对象信息失败!", e);
		}
		return trip;
	}
	/**
	 * 
	 * @param check 审批是否为通过
	 * @param id
	 * @throws BusinessException
	 */
	public void checkData(boolean check,String id,String proKey)throws BusinessException{
		try {
			CheckFolw checkFolw = this.getCheckFolwById(id);
			if(check){
				String nextRole = getNextCheckRole(checkFolw.getEntryRole(),checkFolw.getCheckRole(),proKey);
				if(nextRole.equals("end")){
					checkFolw.setState("100");
					checkFolw.setCheckRole("");
				}else{
					checkFolw.setCheckRole(nextRole);
				}
			}else{
				checkFolw.setCheckRole("");//重新提交审批,CheckRole重新赋值
				checkFolw.setState("-1");//审批驳回
			}
			checkFolw.store(domainProviderSet);//保存对象
		} catch (Exception e) {
			log.error("", e);
			throw this.handleBusinessServiceException("设置审批状态信息对象失败!", e);
		}
	}
}
